#include<stdio.h>
int main(){
    int n,m,c = 0;
    scanf("%d%d",&n,&m);
    int arr[n];
    m = m%n;
    for (int i = 0; i < n; ++i) {
        scanf("%d",&arr[i]);
    }
    for (int i = m; i < n; ++i) {
        printf("%d%s",arr[i],c==n-1?"\n":" ");
        c++;
    }
    for (int i = 0; i < m; ++i) {
        printf("%d%s",arr[i],i==m-1?"\n":" ");
    }
}